package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.mapper.HousekeepingMapper;
import com.ruoyi.system.mapper.TmcUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HousekeepingOrderMapper;
import com.ruoyi.system.domain.HousekeepingOrder;
import com.ruoyi.system.service.IHousekeepingOrderService;

/**
 * 人员订单管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@Service
public class HousekeepingOrderServiceImpl implements IHousekeepingOrderService 
{
    @Autowired
    private HousekeepingOrderMapper housekeepingOrderMapper;
    @Autowired
    private HousekeepingMapper housekeepingMapper;
    @Autowired
    private TmcUserMapper tmcUserMapper;

    /**
     * 查询人员订单管理
     * 
     * @param hoId 人员订单管理ID
     * @return 人员订单管理
     */
    @Override
    public HousekeepingOrder selectHousekeepingOrderById(Long hoId)
    {
        return housekeepingOrderMapper.selectHousekeepingOrderById(hoId);
    }

    /**
     * 查询人员订单管理列表
     * 
     * @param housekeepingOrder 人员订单管理
     * @return 人员订单管理
     */
    @Override
    public List<HousekeepingOrder> selectHousekeepingOrderList(HousekeepingOrder housekeepingOrder)
    {
        List<HousekeepingOrder> housekeepingOrders = housekeepingOrderMapper.selectHousekeepingOrderList(housekeepingOrder);
        for (int i = 0; i <housekeepingOrders.size(); i++) {
            housekeepingOrders.get(i).setHousekeeping(housekeepingMapper.selectHousekeepingById(housekeepingOrders.get(i).getHoHId()));
            housekeepingOrders.get(i).setUser(tmcUserMapper.selectUserByid(housekeepingOrders.get(i).getHoUserId()));
        }
        return housekeepingOrders ;
    }

    /**
     * 新增人员订单管理
     * 
     * @param housekeepingOrder 人员订单管理
     * @return 结果
     */
    @Override
    public int insertHousekeepingOrder(HousekeepingOrder housekeepingOrder)
    {   housekeepingOrder.setCreateTime(DateUtils.getNowDate());
        return housekeepingOrderMapper.insertHousekeepingOrder(housekeepingOrder);
    }

    /**
     * 修改人员订单管理
     * 
     * @param housekeepingOrder 人员订单管理
     * @return 结果
     */
    @Override
    public int updateHousekeepingOrder(HousekeepingOrder housekeepingOrder)
    {housekeepingOrder.setUpdateTime(DateUtils.getNowDate());
        return housekeepingOrderMapper.updateHousekeepingOrder(housekeepingOrder);
    }

    /**
     * 批量删除人员订单管理
     * 
     * @param hoIds 需要删除的人员订单管理ID
     * @return 结果
     */
    @Override
    public int deleteHousekeepingOrderByIds(Long[] hoIds)
    {
        return housekeepingOrderMapper.deleteHousekeepingOrderByIds(hoIds);
    }

    /**
     * 删除人员订单管理信息
     * 
     * @param hoId 人员订单管理ID
     * @return 结果
     */
    @Override
    public int deleteHousekeepingOrderById(Long hoId)
    {
        return housekeepingOrderMapper.deleteHousekeepingOrderById(hoId);
    }
}
